package com.hnevc.animationdemo;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {
    ImageView mIvSplash;
    Handler mHandler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            if(msg.what==101){
                if(msg.arg1>=3){
                    Intent intent = new Intent();
                    intent.setClass(MainActivity.this,LoginActivity.class);
                    startActivity(intent);
                    MainActivity.this.finish();
                }
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mIvSplash = (ImageView) findViewById(R.id.id_iv_splash);
        Animation alpha = AnimationUtils.loadAnimation(this,R.anim.translate_animation);
       /* AlphaAnimation alpha = new AlphaAnimation(0.0f,1.0f);
        alpha.setDuration(8000);
        alpha.setRepeatCount(0);*/
        mIvSplash.startAnimation(alpha);
       /* new Thread(
                new Runnable() {
                    int i=0;
                    @Override
                    public void run() {
                        try {
                            while(true) {
                                Thread.sleep(1000);
                                Message msg = new Message();
                                msg.what = 101;
                                msg.arg1 = i++;
                                mHandler.sendMessage(msg);
                                if(i==4){
                                    break;
                                }
                            }
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
        ).start();*/

    }
}
